﻿#ifndef WEB_SERVER_H
#define WEB_SERVER_H

#include "communicationprotocol.h"
#include "tcp_client.h"
#include "upwardpro.h"

#include <QDateTime>
#include <QObject>
#include <QTime>
#include <QTimer>

#define DEVICE_DATA_CODE "DE01"
#define CHARACTER_DATA_CODE "FE01"

struct WebServerCharacterData_TypeDef {
    std::string data_type_label;
    std::string channel_label;
    std::string character_data_str;
    int time_stamp;
};

struct WebServerDeviceData_TypeDef {
    std::string device_code;
    std::string enterprise_identification_code;
    std::string province_name;
    std::string device_model;
    std::string device_name;
};

class UPWARDPRO_EXPORT Web_Server : public UpwardPro {
    Q_OBJECT
public:
    Web_Server();
    ~Web_Server();
    virtual int objectInit(std::string mode, void* Para_struct) override;
    virtual int sendDeviceData(void* device_struct) override;
    virtual int sendCharacterData(void* character_struct) override;

private:
    CommunicationProtocol* m_protocol;
    WebServerDeviceData_TypeDef* m_webServerDeviceData;
};

static QString m_sn_code;
void SnCodeRecCallback(const char data[]);

#endif // WEB_SERVER_H
